#include "Token.h"



int TokenSequence::lex(ParserBase::STYPE_* value){
    if (index >= tokenSequence.size())
        return 0;
    value->str = &tokenSequence[index].value;
    return tokenSequence[index++].tokenType;
}         
void TokenSequence::resetIndex(){
    index = 0;
}
void TokenSequence::pushToken(int line,ParserBase::Tokens_ tokenType,const std::string& value){
    tokenSequence.push_back({line,tokenType,value});
}

void TokenSequence::show(ofstream& out){
    char buffer[128];
    for(auto& token : tokenSequence){
        sprintf(buffer,"<line:%d, tokenID:%d, value:%s>\n",token.line,token.tokenType,token.value.data());
        out << buffer;
    }
}


TokenSequence tokens;
